<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
</head>

<body>
    <table>
        <tr>
            <td><label>用户名：</label></td>
            <td><input type="text" id="username" placeholder="请输入用户名"></td>
        </tr>
        <tr>
            <td>密码：</td>
            <td><input type="password" id="userpwd" placeholder="请输入密码"></td>
        </tr>
        <tr>
            <td><input type="button" value="登录" onclick="login()"></td>
            <td><input type="button" value="注册" onclick="register()"></td>
        </tr>
    </table>


    <script src="https://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js"></script>
    <script>
        // 登录
        function login() {
            let username = $('[id = username]').val();
            let userpwd = $('[id = userpwd]').val();
            let obj = {
                username,
                userpwd
            }
            $.post('http://localhost:8080/user', obj, function (res) {
                if (res.code === 200) {
                    window.location.href = './index.html'
                    alert(res.msg);
                } else {
                    alert(res.msg);
                }
            })
        }

        // 注册
        function register() {
            window.location.href = './detail.html'
        }
    </script>

</body>

</html>